FROM eclipse-temurin:17-jdk-jammy

# 设置工作目录
WORKDIR /app

# 替换为清华镜像源并安装常用工具（包括 unzip）
RUN sed -i 's@archive.ubuntu.com@mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list && \
    sed -i 's@security.ubuntu.com@mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list && \
    apt-get update && \
    apt-get install -y --no-install-recommends \
        iputils-ping \
        vim \
        unzip && \
    rm -rf /var/lib/apt/lists/*

# 拷贝 jar 包
COPY target/spring-boot-pro-0.0.1-SNAPSHOT.jar app.jar

# 暴露端口
EXPOSE 8001

# 设置启动命令，加入 JVM 参数（可根据需要调整）
ENTRYPOINT ["java", \
    "-Xms256m", \
    "-Xmx512m", \
    "-XX:+UseG1GC", \
    "-XX:MaxGCPauseMillis=200", \
    "-XX:+PrintGCDetails", \
    "-XX:+PrintGCDateStamps", \
    "-Xlog:gc*:file=/app/logs/gc.log:time", \
    "-jar", \
    "app.jar"]